package com.sgg.datastructure.huffmantree;

public class Node implements Comparable<Node> {
    Integer value;
    Node left;
    Node right;

    public Node(Integer value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "Node{" +
                "value=" + value +
                '}';
    }

    @Override
    public int compareTo(Node o) {
        return this.value - o.value;
    }

    /**
     * 前序遍历
     */
    public void preOrderPrint() {
        System.out.println(this.value);
        if (this.left != null) {
            this.left.preOrderPrint();
        }
        if (this.right != null) {
            this.right.preOrderPrint();
        }
    }


}
